<html>
<head><meta charset="utf-8"><title>Instance.to_string() panic in release · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Instance.2Eto_string().20panic.20in.20release.html">Instance.to_string() panic in release</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241434530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Instance.to_string%28%29%20panic%20in%20release/near/241434530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexa VanHattum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Instance.2Eto_string().20panic.20in.20release.html#241434530">(Jun 03 2021 at 18:42)</a>:</h4>
<p>I'm  running into a panic from calling <code>.to_string()</code> on an instance of <code>rustc_middle::ty::instance::Instance</code> in release mode, despite the line working as expected in debug mode. Looking over the <a href="https://github.com/rust-lang/rust/blob/257782579915963c9dbe7433102275743837b9a8/compiler/rustc_middle/src/ty/instance.rs#L259">implementation of</a> <code>Display</code>,  I don't see anything obvious that would cause a different in behavior in debug mode.</p>
<p>This is happening in the context of a custom Rust backend in the <a href="https://github.com/model-checking/rmc">RMC project</a>, and the exact line of code causing the issue can be seen in <a href="https://github.com/avanhatt/rmc/commit/70d460e81515832531712866006b63b6f2180fa4">this commit</a>. Without this line, both debug and release do not panic/work as expected. </p>
<p>The panic trace is listed below. I have <code>RUSTFLAGS="-Z trim-diagnostic-paths=no"</code> set. </p>
<p>I'm new to working with the Rust compiler internals, so please let me know if this is not the right place to ask for help!</p>
<div class="codehilite"><pre><span></span><code>error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: std::backtrace_rs::backtrace::libunwind::trace
                       at ./library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
                std::backtrace_rs::backtrace::trace_unsynchronized
                       at ./library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
                std::backtrace::Backtrace::create
                       at ./library/std/src/backtrace.rs:327:13
             1: std::backtrace::Backtrace::force_capture
                       at ./library/std/src/backtrace.rs:310:9
             2: rustc_errors::Handler::delay_good_path_bug
             3: rustc_middle::ty::print::pretty::trimmed_def_paths
             4: rustc_query_impl::&lt;impl rustc_query_system::query::config::QueryAccessors&lt;rustc_query_impl::plumbing::QueryCtxt&gt; for rustc_query_impl::queries::trimmed_def_paths&gt;::compute
             5: rustc_data_structures::stack::ensure_sufficient_stack
             6: rustc_query_system::query::plumbing::get_query_impl
             7: rustc_query_system::query::plumbing::get_query
             8: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
             9: rustc_middle::ty::print::Printer::default_print_def_path
            10: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
            11: rustc_middle::ty::print::Printer::default_print_def_path
            12: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
            13: &lt;rustc_middle::ty::instance::Instance as core::fmt::Display&gt;::fmt
            14: rustc_codegen_llvm::gotoc::&lt;impl rustc_codegen_llvm::gotoc::metadata::GotocCtx&gt;::declare_function
            15: &lt;rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend&gt;::codegen_crate
            16: rustc_session::utils::&lt;impl rustc_session::session::Session&gt;::time
            17: rustc_interface::passes::start_codegen
            18: rustc_interface::passes::QueryContext::enter
            19: rustc_interface::queries::Query&lt;T&gt;::compute
            20: rustc_interface::queries::Queries::ongoing_codegen
            21: rustc_driver::run_compiler::{{closure}}::{{closure}}
                       at ./compiler/rustc_driver/src/lib.rs:414:13
                rustc_interface::queries::&lt;impl rustc_interface::interface::Compiler&gt;::enter
                       at ./compiler/rustc_interface/src/queries.rs:432:19
            22: rustc_driver::run_compiler::{{closure}}
                       at ./compiler/rustc_driver/src/lib.rs:313:22
                rustc_interface::interface::create_compiler_and_run::{{closure}}
                       at ./compiler/rustc_interface/src/interface.rs:208:13
                rustc_span::with_source_map
                       at ./compiler/rustc_span/src/lib.rs:870:5
            23: rustc_interface::interface::create_compiler_and_run
                       at ./compiler/rustc_interface/src/interface.rs:202:5
            24: rustc_interface::interface::run_compiler::{{closure}}
                       at ./compiler/rustc_interface/src/interface.rs:224:12
                rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
                       at ./compiler/rustc_interface/src/util.rs:152:13
                scoped_tls::ScopedKey&lt;T&gt;::set
                       at /Users/avanhatt/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
            25: rustc_span::with_session_globals
                       at ./compiler/rustc_span/src/lib.rs:104:5
            26: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
                       at ./compiler/rustc_interface/src/util.rs:150:9
                rustc_interface::util::scoped_thread::{{closure}}
                       at ./compiler/rustc_interface/src/util.rs:125:24
                std::sys_common::backtrace::__rust_begin_short_backtrace
                       at ./library/std/src/sys_common/backtrace.rs:125:18
            27: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}
                       at ./library/std/src/thread/mod.rs:481:17
                &lt;std::panic::AssertUnwindSafe&lt;F&gt; as core::ops::function::FnOnce&lt;()&gt;&gt;::call_once
                       at ./library/std/src/panic.rs:347:9
                std::panicking::try::do_call
                       at ./library/std/src/panicking.rs:401:40
                std::panicking::try
                       at ./library/std/src/panicking.rs:365:19
            28: std::panic::catch_unwind
                       at ./library/std/src/panic.rs:434:14
                std::thread::Builder::spawn_unchecked::{{closure}}
                       at ./library/std/src/thread/mod.rs:480:30
                core::ops::function::FnOnce::call_once{{vtable.shim}}
                       at ./library/core/src/ops/function.rs:227:5
            29: &lt;alloc::boxed::Box&lt;F,A&gt; as core::ops::function::FnOnce&lt;Args&gt;&gt;::call_once
                       at ./library/alloc/src/boxed.rs:1575:9
                &lt;alloc::boxed::Box&lt;F,A&gt; as core::ops::function::FnOnce&lt;Args&gt;&gt;::call_once
                       at ./library/alloc/src/boxed.rs:1575:9
            30: std::sys::unix::thread::Thread::new::thread_start
                       at ./library/std/src/sys/unix/thread.rs:71:17
            31: __pthread_start


thread &#39;rustc&#39; panicked at &#39;no warnings or errors encountered even though `delayed_good_path_bugs` issued&#39;, compiler/rustc_errors/src/lib.rs:1021:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&amp;template=ice.md

note: rustc 1.54.0-dev running on x86_64-apple-darwin

note: compiler flags: -Z codegen-backend=gotoc

query stack during panic:
end of query stack
</code></pre></div>



<a name="241434967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Instance.to_string%28%29%20panic%20in%20release/near/241434967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Instance.2Eto_string().20panic.20in.20release.html#241434967">(Jun 03 2021 at 18:46)</a>:</h4>
<p><span class="user-mention" data-user-id="418083">@Alexa VanHattum</span> Try wrapping the <code>.to_string()</code> call in a <code>rustc_middle::ty::print::with_no_trimmed_paths()</code> call. You shouldn't need <code>-Ztrim-diagnostic-path=no</code> in that case either.</p>



<a name="241435660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Instance.to_string%28%29%20panic%20in%20release/near/241435660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexa VanHattum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Instance.2Eto_string().20panic.20in.20release.html#241435660">(Jun 03 2021 at 18:51)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> that seems to work, thank you so much!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>